<?php Yii::app()->clientScript->registerScriptFile(Yii::app()->params['static'].'assets/js/bootbox.min.js',2); ?>
<div class="page-header">
							<h1>
							个人通知
							</h1><p>（辅导员对您的提交信息的审核意见）</p>
</div>
<div class="row">
 <div class="col-sm-12">
    <div class="row">

		<div class="col-xs-12">
		    <div class="widget-box">
											<div class="widget-header widget-header-small">
												<h5>有 <?php echo $total; ?> 条个人通知未读</h5>
											</div>

											<div class="widget-body">
												<div class="widget-main">
											<div class="table-responsive">
										<div class="table-responsive">
											<table id="sample-table-1" class="table table-striped table-bordered table-hover">
												<thead>
													<tr>
													   <th>模块</th>
													    <th>条目</th>
														<th>添加时间</th>
														<th>老师建议</th>
														<th>
														<i class="icon-wrench bigger-110 hidden-480"></i>
														已阅
														</th>
													</tr>
												</thead>

												<tbody>
												<?php
												
											    foreach($nos  as $n){
													//1 -- 个人信息 2 -- 综合奖学金 3 -- GSP 4---综合素质 5 -- 学生活动
													$module = ''; 
													switch($n->module){
														case '1': $module = '个人信息';break;
														case '2': $module = '综合奖学金';break;
														case '3': $module = 'GSP';break;
														case '4': $module = '综合素质';break;
														case '5': $module = '学生活动';break;
														
													}
												echo'	
												<tr id="'.$n->stuNotificationId.'">
												
												<td>'.$module.'</td>
												<td><a class="get-detail" detailId="'.$n->detailId.'" module = "'.$n->module.'">条目详情</a></td>
												<td>'.$n->addtime.'</td>
												<td><h5 class="red">'.$n->comment.'</h5></td>
												
												
												<td>
															<div class="visible-md visible-lg hidden-sm hidden-xs btn-group">
												              
																
																<a target="_blank" isChecked ="'.$n->stuNotificationId.'" >
																<button  class="btn btn-xs btn-success">
																	<i class="icon-check bigger-120"></i>
																</button>
																</a>
															</div>

												</td>
											    </tr>';
												}
                                               ?>												
											    </tbody>
											
											</table>
									       
									</div><!-- /.table-responsive -->
		</div>
     </div>
										
	</div>
	</div>
	</div>
 </div>
 </div>
</div>
<script type="text/javascript">

			jQuery(function($) {
				$('.get-detail').on('click',function(){
					var id = $(this).attr('detailId');
					var module = $(this).attr('module');
					var text = '';
					$.post('<?php echo Yii::app()->createUrl('stunotify/getdata') ?>',{'id':id,'module':module},function(data){
						data = $.parseJSON(data);
						if(data == false){
							bootbox.alert('没有找到这一条目，可能已经被删除',function(){
								
							});
						}else{
							for(var key in data){
								
								text += '<tr><td>'+key+'</td><td>'+data[key]+'</td></tr>';
							}
							console.log(text);
							bootbox.dialog({
								title: "详细信息",
								message: '<table id="sample-table-1" class="table table-striped table-bordered table-hover"><thead><tr> <th>项目</th><th>值</th></thead><tbody>'+text+'</tbody></table>',
							}); 
						
			          }
					});
					  
					
				});
				
				$('[isChecked]').on("click",function(){
					var id = $(this).attr('isChecked');
					bootbox.confirm("确定已经读过这条通知了吗?", function(result) {
						   if(result){
							   $.post('<?php echo Yii::app()->createUrl('stunotify/readone')?>',{'id':id},function(data){
								   data = $.parseJSON(data);
								   bootbox.alert(data['msg'],function(){
									   if(data['code'] == '200'){
										   $('#'+id).fadeToggle('800','linear',function(){
											   $(this).remove();
											   
										   });
										   
									   }
									   
								   });
								   
							   });
							   
						   
						   }		
				    }); 
				   	
				})
								
			})
		
</script>